package utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.providers;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
import org.eclipse.gmf.runtime.notation.View;

import utn.frsf.cidisi.upcolbpip.interactionprotocols.InteractionprotocolsPackage;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.BusinessMessageNameEditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.ControlFlowSegmentOperator2EditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.ControlFlowSegmentOperatorEditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.InteractionPathNameEditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.ProtocolReferenceName2EditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.ProtocolReferenceNameEditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.RoleNameEditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.TerminationTerminationElement2EditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts.TerminationTerminationElementEditPart;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.parsers.MessageFormatParser;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.part.UpcolbpipVisualIDRegistry;

/**
 * @generated
 */
public class UpcolbpipParserProvider extends AbstractProvider implements
		IParserProvider {

	/**
	 * @generated
	 */
	private IParser roleName_5012Parser;

	/**
	 * @generated
	 */
	private IParser getRoleName_5012Parser() {
		if (roleName_5012Parser == null) {
			roleName_5012Parser = createRoleName_5012Parser();
		}
		return roleName_5012Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createRoleName_5012Parser() {
		EAttribute[] features = new EAttribute[] { InteractionprotocolsPackage.eINSTANCE
				.getRole_Name(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser terminationTerminationElement_5010Parser;

	/**
	 * @generated
	 */
	private IParser getTerminationTerminationElement_5010Parser() {
		if (terminationTerminationElement_5010Parser == null) {
			terminationTerminationElement_5010Parser = createTerminationTerminationElement_5010Parser();
		}
		return terminationTerminationElement_5010Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createTerminationTerminationElement_5010Parser() {
		EAttribute[] features = new EAttribute[] { InteractionprotocolsPackage.eINSTANCE
				.getTermination_TerminationElement(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser protocolReferenceName_5005Parser;

	/**
	 * @generated
	 */
	private IParser getProtocolReferenceName_5005Parser() {
		if (protocolReferenceName_5005Parser == null) {
			protocolReferenceName_5005Parser = createProtocolReferenceName_5005Parser();
		}
		return protocolReferenceName_5005Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createProtocolReferenceName_5005Parser() {
		EAttribute[] features = new EAttribute[] { InteractionprotocolsPackage.eINSTANCE
				.getInteractionProtocolElement_Name(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		parser.setViewPattern("Ref: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser controlFlowSegmentOperatorName_5006Parser;

	/**
	 * @generated
	 */
	private IParser getControlFlowSegmentOperatorName_5006Parser() {
		if (controlFlowSegmentOperatorName_5006Parser == null) {
			controlFlowSegmentOperatorName_5006Parser = createControlFlowSegmentOperatorName_5006Parser();
		}
		return controlFlowSegmentOperatorName_5006Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createControlFlowSegmentOperatorName_5006Parser() {
		EAttribute[] features = new EAttribute[] {
				InteractionprotocolsPackage.eINSTANCE
						.getControlFlowSegment_Operator(),
				InteractionprotocolsPackage.eINSTANCE
						.getInteractionProtocolElement_Name(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		parser.setViewPattern("{0} - {1}");
		parser.setEditorPattern("{0}{1}");
		parser.setEditPattern("{0}{1}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser interactionPathName_5008Parser;

	/**
	 * @generated
	 */
	private IParser getInteractionPathName_5008Parser() {
		if (interactionPathName_5008Parser == null) {
			interactionPathName_5008Parser = createInteractionPathName_5008Parser();
		}
		return interactionPathName_5008Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createInteractionPathName_5008Parser() {
		EAttribute[] features = new EAttribute[] { InteractionprotocolsPackage.eINSTANCE
				.getInteractionPath_Name(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		parser.setViewPattern("[{0}]");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser controlFlowSegmentOperatorName_5007Parser;

	/**
	 * @generated
	 */
	private IParser getControlFlowSegmentOperatorName_5007Parser() {
		if (controlFlowSegmentOperatorName_5007Parser == null) {
			controlFlowSegmentOperatorName_5007Parser = createControlFlowSegmentOperatorName_5007Parser();
		}
		return controlFlowSegmentOperatorName_5007Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createControlFlowSegmentOperatorName_5007Parser() {
		EAttribute[] features = new EAttribute[] {
				InteractionprotocolsPackage.eINSTANCE
						.getControlFlowSegment_Operator(),
				InteractionprotocolsPackage.eINSTANCE
						.getInteractionProtocolElement_Name(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		parser.setViewPattern("{0} - {1}");
		parser.setEditorPattern("{0}{1}");
		parser.setEditPattern("{0}{1}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser protocolReferenceName_5009Parser;

	/**
	 * @generated
	 */
	private IParser getProtocolReferenceName_5009Parser() {
		if (protocolReferenceName_5009Parser == null) {
			protocolReferenceName_5009Parser = createProtocolReferenceName_5009Parser();
		}
		return protocolReferenceName_5009Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createProtocolReferenceName_5009Parser() {
		EAttribute[] features = new EAttribute[] { InteractionprotocolsPackage.eINSTANCE
				.getInteractionProtocolElement_Name(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		parser.setViewPattern("Ref: {0}");
		parser.setEditorPattern("{0}");
		parser.setEditPattern("{0}");
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser terminationTerminationElement_5011Parser;

	/**
	 * @generated
	 */
	private IParser getTerminationTerminationElement_5011Parser() {
		if (terminationTerminationElement_5011Parser == null) {
			terminationTerminationElement_5011Parser = createTerminationTerminationElement_5011Parser();
		}
		return terminationTerminationElement_5011Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createTerminationTerminationElement_5011Parser() {
		EAttribute[] features = new EAttribute[] { InteractionprotocolsPackage.eINSTANCE
				.getTermination_TerminationElement(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		return parser;
	}

	/**
	 * @generated
	 */
	private IParser businessMessageName_6001Parser;

	/**
	 * @generated
	 */
	private IParser getBusinessMessageName_6001Parser() {
		if (businessMessageName_6001Parser == null) {
			businessMessageName_6001Parser = createBusinessMessageName_6001Parser();
		}
		return businessMessageName_6001Parser;
	}

	/**
	 * @generated
	 */
	protected IParser createBusinessMessageName_6001Parser() {
		EAttribute[] features = new EAttribute[] { InteractionprotocolsPackage.eINSTANCE
				.getInteractionProtocolElement_Name(), };
		MessageFormatParser parser = new MessageFormatParser(features);
		return parser;
	}

	/**
	 * @generated
	 */
	protected IParser getParser(int visualID) {
		switch (visualID) {
		case RoleNameEditPart.VISUAL_ID:
			return getRoleName_5012Parser();
		case TerminationTerminationElementEditPart.VISUAL_ID:
			return getTerminationTerminationElement_5010Parser();
		case ProtocolReferenceNameEditPart.VISUAL_ID:
			return getProtocolReferenceName_5005Parser();
		case ControlFlowSegmentOperatorEditPart.VISUAL_ID:
			return getControlFlowSegmentOperatorName_5006Parser();
		case InteractionPathNameEditPart.VISUAL_ID:
			return getInteractionPathName_5008Parser();
		case ControlFlowSegmentOperator2EditPart.VISUAL_ID:
			return getControlFlowSegmentOperatorName_5007Parser();
		case ProtocolReferenceName2EditPart.VISUAL_ID:
			return getProtocolReferenceName_5009Parser();
		case TerminationTerminationElement2EditPart.VISUAL_ID:
			return getTerminationTerminationElement_5011Parser();
		case BusinessMessageNameEditPart.VISUAL_ID:
			return getBusinessMessageName_6001Parser();
		}
		return null;
	}

	/**
	 * @generated
	 */
	public IParser getParser(IAdaptable hint) {
		String vid = (String) hint.getAdapter(String.class);
		if (vid != null) {
			return getParser(UpcolbpipVisualIDRegistry.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(UpcolbpipVisualIDRegistry.getVisualID(view));
		}
		return null;
	}

	/**
	 * @generated
	 */
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (UpcolbpipElementTypes.getElement(hint) == null) {
				return false;
			}
			return getParser(hint) != null;
		}
		return false;
	}

	/**
	 * @generated
	 */
	public static class HintAdapter extends ParserHintAdapter {

		/**
		 * @generated
		 */
		private final IElementType elementType;

		/**
		 * @generated
		 */
		public HintAdapter(IElementType type, EObject object, String parserHint) {
			super(object, parserHint);
			assert type != null;
			elementType = type;
		}

		/**
		 * @generated
		 */
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return elementType;
			}
			return super.getAdapter(adapter);
		}
	}

}
